home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / szadb1_4.zoo / doc / lpr / szadb.doc < prev   
Encoding:
Text File  |  1991-07-08  |  19.3 KB  |  521 lines

  1.  
  2. NAME
  3.  
  4.     szadb - Sozobon debugger, version 1.4
  5.  
  6. USAGE
  7.  
  8.     szadb [[-nc] [-nb] [-k defs] [-om] [-os]] program [args]
  9.  
  10. where 'args' is an optional command line to be passed to 'program'.
  11.  
  12. SUMMARY
  13.  
  14. Szadb is a machine language debugger with symbols which is similar to
  15. the old UNIX 'adb' command.  Szadb is used to control and monitor
  16. another program.  This program is loaded into memory and relocated
  17. when szadb is first started.  Commands to szadb allow the user to
  18. examine and modify memory and machine registers, single step and set
  19. breakpoints.  Szadb was written as a companion debugger for Sozobon C
  20. compiler, but it can be used with other compilers which can produce a
  21. symbol table in the same format (Alcyon C, ST version of gcc with
  22. small modifications - c.f. "Primer" for details).  Version 1.2 also
  23. understands symbols created by Mark Williams C and attempts to adjust
  24. itself to this format automatically.  Use options -om and -os if the
  25. debugger got confused.  Version 1.3 adds a support for long symbols
  26. names in "GST format" which are produced by newer versions of gcc
  27. loader when -G flag is used.  Version 1.4 frees szadb from hardwired
  28. screen parameters which allows for use on TT in all screen
  29. resolutions.  This does not mean yet a support for non-68000
  30. instructions.  This would be pretty easy to add but is left for a
  31. person or persons with TT and necessary MC68020/30 references on hand.
  32. Version 1.4 allows also a use of szadb with Moniterm, but this
  33. requires an additional ST monitor connected in parallel, due to a way
  34. in which Moniterm driver operates.  Check details in "Primer".
  35.  
  36. OPTIONS
  37.  
  38.     -nc  disallow commands stored with breakpoints; saves some
  39.          memory
  40.  
  41.     -nb  turn off buffering of output which goes to a trancript
  42.          file; saves memory but a usage of '$>file' request is
  43.          then not recommended
  44.  
  45.     -k   the following argument is a name of a file with function
  46.          key definitions; see FUNCTION KEYS for details.
  47.  
  48.     -om  'program' is an executable in MWC format
  49.  
  50.     -os  'program' is an executable in Sozobon C format
  51.  
  52.  
  53. WINDOWS
  54.  
  55. Szadb uses its own window or screen.  Thus commands and output will
  56. not interfere with the program's window.  In fact, szadb does output
  57. without using the BIOS so as not to confuse the program's cursor.
  58.  
  59. Use <cntl-w> to view the program's screen when you are in the szadb
  60. window.  Type another character to get back.
  61.  
  62.  
  63. ONLINE HELP
  64.  
  65. A summary of this manual is available by typing the 'help' key.  Use 'q'
  66. to get back to the szadb prompt.  Typing any other key will advance to the
  67. next help screen.
  68.  
  69. People in other countries are encouraged to come up with versions of szadb
  70. with the messages in their language.  You should only have to change the one
  71. file "lang.h".
  72.  
  73.  
  74. SYNTAX
  75.  
  76. In the following description of commands, certain syntactic abbreviations
  77. are used.
  78.  
  79.     {expr}   - any valid expression consisting of numbers, symbols and
  80.            operators.  See the section on EXPRESSIONS
  81.        ,{count}  - a repeat count for the command.  Can be any expression
  82.     {format} - a string of characters which specifies how values are
  83.            printed. See the section on FORMATS
  84.     {args}     - The arguments or parameters to be passed to the program
  85.     {value}  - an additional expression used by the command
  86.     {line}     - any string which will fit on a command line
  87.  
  88. FORMAT OF COMMANDS
  89.  
  90. The general format for command X is
  91.  
  92.     {expr},{count}X            for most commands
  93. or    {expr},{count}X{format}        for / or ? or =
  94. or    {expr},{count}X{args}        for :c
  95. or    {expr},{count}X{value}        for /w or /W
  96. or    {expr},{count}X{line}        for :b, :s, :n, :f
  97.  
  98. Spaces and tabs can be input to improve readability.  They are always
  99. ignored.
  100.  
  101. All fields are optional.  If {count} is missing, we do the command once.
  102. If {format} is missing we re-use the last {format}.  If {args} are missing,
  103. no parameters are passed.  If {values} are missing, nothing is written.
  104. There could be multiple commands on one input line if they are 
  105. separated by semicolon ';'.
  106.  
  107. Any string will be accepted as an argument {line} which occurs in a format
  108. for :b, :s, :n, and :f.  Stepping commands with non-empty argument do not
  109. step through any program instructions.  If -nc option is not used then the
  110. string {line} will be stored and later szadb will attempt to execute it when
  111. a breakpoint is hit or a stepping command with an empty argument is be
  112. called.  The user is solely responsible for makine a {line} into a string
  113. of valid szadb requests if (s)he wants to anything else but an error
  114. message.  Setting the same breakpoint or calling stepping command with a
  115. new argument will replace the stored line with a new one.
  116.  
  117. If {expr} is missing, we use the value of DOT.  DOT is set to the PC after
  118. we single step or hit a breakpoint.  DOT is set to {expr} by most commands.
  119. DOT is set to the next address after locations that were printed by
  120. the / or ? command.
  121.  
  122. If the command is missing, we use the last command.  Thus an empty line
  123. repeats the last command with DOT for the {expr} and 1 for the {count}
  124. (and {format} the same as before).
  125.  
  126.  
  127. THE ':' GROUP
  128.  
  129.     :s or :S
  130.  
  131.     This command is used to single step the program.  It will use the
  132.     trace bit of the 68000 to force a trap after one instruction.
  133.     We do not switch to the program window for single stepping.
  134.  
  135.     :c or :C
  136.  
  137.     This command is used to continue the program.  We will switch to
  138.     the program window and run at full speed until a breakpoint is
  139.     hit, a trap occurs or the program exits. 
  140.  
  141.     :n or :N
  142.  
  143.     Like :s, but the program does not descend into subroutines.
  144.     The command :c is used when a subroutine call encountered with
  145.     an automatic stop upon return to the caller.  If any breakpoints
  146.     were set inside of such subroutine they wll be obeyed.
  147.  
  148.     :j or :J
  149.  
  150.     A version of :n which will skip the next instruction if it is
  151.     a branch.  It reverts automatically to :n for purposes of
  152.     autorepeating.  An argument accepted will be also these one
  153.     for :n.  There is no check if an instructions which follows
  154.     a skipped branch can be actually reached.
  155.  
  156.     :f or :F
  157.  
  158.     Execute all command in the current subroutine and stop upon
  159.     return to the caller.  Any breakpoints found will be obeyed.
  160.  
  161.     The upper case versions of each command print all the machine
  162.     registers after running the program.
  163.  
  164.     If parameters of the program were not passed on a command
  165.     line then can be specified as a string {args} which follows
  166.     the first :c  executed in a debugging session.
  167.  
  168.     If an {expr} field is given to the :c or :s, the PC is set to
  169.     that value.  This should be used with care!
  170.  
  171.     :b  -  set a breakpoint at {expr}
  172.     :d  -  delete the breakpoint at {expr}
  173.     ::  -  control execution of commands attached to :b, :s, :n or :f;
  174.            see EXECUTION CONTROL
  175.  
  176. Note that the only way to re-start the program is to exit szadb and start
  177. over.
  178.  
  179. THE '$' GROUP
  180.  
  181.     $q    - quit szadb
  182.     $r    - print all register values
  183.     $e    - print all external symbols and their values
  184.           This display will stop at the bottom of every screen and
  185.           will wait for a keypress.  Keys 'q', 'Q' and ctrl-C will
  186.           terminate, any other key will continue.  Printing is done
  187.           when you will see back szadb prompt '> '.
  188.     $o    - use octal numbers
  189.     $x    - use hex numbers
  190.     $d    - use decimal numbers
  191.       $s    - set the maximum symbol offset to {expr}
  192.           When address are printed by szadb, they are printed as
  193.           symbol+offset if offset is <= to this value
  194.     $b    - print all breakpoints with their optional commands
  195.               and print active commands attached to stepping requests
  196.     $c    - print a stack backtrace
  197.     $C    - print a stack backtrace with arguments
  198.           If szadb cannot determine the number of arguments
  199.           (because there were none or because the optimizer was used),
  200.           it prints the location on the stack where they might be
  201.     $p    - print the basepage of the program
  202.     $><nam> - append all szadb output to a transcript file named '<nam>'
  203.           If a string '<nam>' is empty or different from the previosly
  204.           used then flush output buffers and close the transcript;
  205.           open a new one with a new name if '<nam>' non-empty.
  206.           Transcript output is internally buffered by default
  207.           unless -nb option is used.
  208.     $k    - display all function key definitions
  209.     $k<num> - if <num> is a decimal number between 1 and 20 execute
  210.           an associated function key definition as a sequence of
  211.           szadb commands
  212.  
  213.  
  214. THE '/' or '?' GROUP
  215.  
  216. UNIX adb uses '?' to examine a program file and '/' to look at running
  217. process's memory.  Since szadb only looks at memory, either can be used.
  218. We recommend using '/' since later versions of szadb may use '?' for files.
  219.  
  220.     /
  221.  
  222.     Print values from memory according to a format.  See FORMATS.
  223.     {expr} gives the starting address to fetch values from.
  224.     If there is more than one format character, we increment the
  225.     address used by the size of the value printed.
  226.  
  227.     /w    - Write a 2-byte value to memory at address {expr}
  228.     /W    - Write a 4-byte value to memory at address {expr}
  229.  
  230. THE '=' COMMAND
  231.  
  232.     =
  233.  
  234.     Print the value of {expr} according to a format.  See FORMATS.
  235.     If there is more than one format character, we print the same
  236.     value each time.
  237.  
  238. THE '>' GROUP
  239.  
  240. Register values can be changed using '>' followed by the register name.
  241. This sets that register to the value of {expr}.  See REGISTER NAMES
  242.  
  243. THE '<' GROUP
  244.  
  245. Register or a special variable value can be retrieved using '>' followed
  246. by the register or variable name.  See REGISTER NAMES and SPECIAL VARIABLES
  247.  
  248.  
  249. FORMATS
  250.  
  251. Formats are similar to printf() format strings.  They specify the way
  252. values are printed.  However, since we almost always want to print a
  253. value and not some literal string, the '%' before each format is missing.
  254. Also, we usually use upper case for long values instead of a leading 'l'.
  255. Thus %d%lx%o becomes dXo.
  256.  
  257.     d  - print 2-bytes as decimal
  258.     D  - print 4-bytes as decimal
  259.     x  - print 2-bytes as hex
  260.     X  - print 4-bytes as hex
  261.     o  - print 2-bytes as octal
  262.     O  - print 4-bytes as octal
  263.     c  - print a single character
  264.     b  - print 1-byte as octal
  265.     s  - print a string
  266.  
  267. In addition, we add the following non-printf-like formats:
  268.  
  269.     i  - print a single machine language instruction
  270.     S  - print a string with '.' for special characters
  271.     p  - print the current value of DOT as a symbol plus offset
  272.     a  - same as p except also print a ':' and tab
  273.     r  - print a space
  274.     n  - print a newline
  275.     t  - tab to the next tab stop of a given width (see below)
  276.  "string"  - print a literal string
  277.     +  - increment DOT (nothing printed)
  278.     -  - decrement DOT (nothing printed)
  279.     ^  - backup DOT by the last size printed
  280.  
  281. Formats can also be preceeded by a number in a current base.  This number
  282. is usually the repeat count for the next format.  Thus instead of saying
  283. main/iiiiXXXXXX you can say main/4i6X
  284.  
  285. The 't' format is always preceeded by a number.  This format advances to
  286. the next tab stop which a multiple of that number.  For example, 8t moves
  287. to the next 8-space tabstop.
  288.  
  289.  
  290. EXPRESSIONS
  291.  
  292.     Expressions are a lot like C expressions.  They include numbers
  293. and symbols with unary and binary operators.  Expressions are always
  294. evaluated using long (4-byte) arithmetic.  Parenthesis can be used for
  295. grouping.  There is no precedence among binary operators - evaluation is
  296. strictly left to right.
  297.  
  298.     NUMBERS
  299.  
  300.     Numbers can be entered in any base.  A base is specified using one
  301. of the following prefixes:
  302.  
  303.     0x - hex
  304.     0t - decimal
  305.     0o - octal
  306.  
  307.     If there is no such prefix, the default base will be used.  The
  308. default base when you start szadb is hex.  Use a leading 0 if you need
  309. to enter a hex number which starts with a letter.
  310.  
  311.     SYMBOLS
  312.  
  313.     If your program has a symbol table, these symbol names can be
  314. used in expressions.  The value of a symbol is the address of that
  315. variable or function.  Although the C compiler adds a leading '_' to
  316. all symbols, the symbol name will be found with or without the '_'.
  317.  
  318.     OTHER VALUES
  319.  
  320.     Character literals can be entered by enclosing one to four
  321. characters in single quotes.  Multi-character literals put the first
  322. character in the highest byte.
  323.  
  324.     The value of DOT can be used in an expression by typing "."
  325.  
  326.     Use "&" to represent the last typed {expr} field.  (DOT
  327. changes when you print with / or ?.  "&" does not.)
  328.  
  329.     UNARY OPERATORS
  330.  
  331.     -   unary minus (2-s complement)
  332.     ~   bitwise complement (1-s complement)
  333.     *   fetch of 4 bytes from an address
  334.     @   fetch of 2 bytes from an address
  335.  
  336.     BINARY OPERATORS
  337.  
  338.     +   addition
  339.     -   subtraction
  340.     *   multiplication
  341.     %   division (NOT '/' !)
  342.     &   bitwise and
  343.     |   bitwise or
  344.  
  345.  
  346. REGISTER NAMES
  347.  
  348. Szadb uses the standard Motorola register names with 'sp' for 'a7'.
  349. Actually, there are two stack pointers which Motorola calls 'usp' for
  350. the user stack pointer and 'ssp' for the supervisor stack pointer.
  351. Szadb calls the other stack pointer 'xsp'.  This will be 'ssp' if
  352. your program is running in user mode (as it usually is) or 'usp' if
  353. it is running in supervisor mode.
  354.  
  355.  
  356. SPECIAL VARIABLES
  357.  
  358. Szadb provides four special read only variables which describe
  359. a layout of the program in a memory.  They are 
  360.  
  361.         l       lowest text address
  362.         t       length of the text segment
  363.         b       start of the bss segment
  364.         d       length of the data segment
  365.  
  366.  
  367.  
  368. FUNCTION KEYS
  369.  
  370. Szadb recognizes twenty function keys with numbers from 1 to 20, where
  371. first ten numbers correspond to markings on a keyboard and other denote
  372. function keys pressed together with a "Shift" key.
  373.  
  374. One may optionally asign strings to functions keys by reading definitions
  375. from a file which name follows -k argument to szadb.  Every definition 
  376. should start in the first column with an uppercase 'F' followed by a key
  377. number and optional white space.  A trailing string will be stored as the
  378. key definition.  Definitions can be continued on the following lines if
  379. end-of-line character(s) are escaped with a '\' character.  All other
  380. lines and attemps of redefinition of already defined keys will be ignored.
  381. A maximal length of a definition is limited by quite generous (around
  382. 2K for this version).
  383.  
  384. When function key is pressed then as many characters from its definition
  385. string as it will fit will be appended to teh current szadb input line.
  386. The cursor will be put at the end and a resulting sequence of szadb
  387. commands can be edited.
  388.  
  389. An entire definition of a function key can be execucuted by usind $k
  390. request followed by a corresponding function key number (decimal).
  391. A request $k by itself will display a list of all function key definitions.
  392.  
  393.  
  394.  
  395. EXECUTION CONTROL
  396.  
  397. Commands attached to :b and stepping commands :s, :n and :f can be
  398. switched off and on without destroying a stored string.  A special form
  399. {expr}::b- turns off executions of a string stored with a breakpoint
  400. at an address {expr}.  To reverse that action use {expr}::b+.  A similar
  401. form works also for stepping commands.
  402.  
  403. A request :f has a special default action attached.  When overtyped
  404. or switched off can be always restored by a use of ::f` request.
  405.  
  406. Stepping commads :f and :n can also have their attached commands "shifted"
  407. by a use of ::f_ and ::n_ requests.  This will cause for :f a switch
  408. of attached command string to this for :n or :s (in that order) and for
  409. :n a switch to a strig for :s.  This switch only takes place if 
  410. corresponding command strings are defined and active.  Requests
  411. ::n+, ::f+ or ::f` will restore an original actions.  Status of all
  412. stepping commands is displayed after $b request.
  413.  
  414.  
  415.  
  416. SPECIAL CHARACTERS
  417.  
  418. When entering a command, use the left-arrow (backspace) to erase typed
  419. characters.  When a lot of output is being printed, you can use cntl-S
  420. to suspend output temporarily or cntl-C to stop the command.
  421.  
  422. Use the help key to get a summary of this document from within szadb.
  423.  
  424.  
  425. MAGIC STUFF
  426.  
  427. Szadb works by changing the trap vectors to point to itself.  If you
  428. try to debug any program which changes the trap vectors, szadb will not
  429. work.
  430.  
  431. Breakpoints cannot be set on ROM locations, but szadb will not give you
  432. an error if you try.
  433.  
  434. Various shells do funny things to parameters.  Szadb does not Upper-case
  435. arguments and does not pass more than 128 bytes of parameters (but
  436. see examples in "Primer" how to circumvent this limitation).
  437.  
  438. Programs compiled with the dLibs startup routine (e.g. most programs
  439. compiled with Sozobon C) do funny things to try to determine argv[0].
  440. In particular a pointer to the parent's basepage is followed.  Szadb
  441. does not set up this pointer, so argv[0] is not passed under szadb.
  442.  
  443. Programs compiled with other compilers, or written in assembler, may use
  444. different calling conventions and an organization of stack frames.
  445. This may cause difficulties to requests like $c and :f.  Use your better
  446. judgement.
  447.  
  448. Certain programs only work when loaded at a certain address (or only
  449. fail when loaded at a certain address).  Running a program under szadb
  450. changes where that program is loaded.  Thus behavior under szadb may
  451. be different from what happens otherwise.
  452.  
  453. Programs with bugs may modify random locations of memory.  If they 
  454. happen to modify a value that is part of szadb, szadb will probably
  455. die.  Unfortunately, this isn't UNIX.
  456.  
  457.  
  458. SEE ALSO
  459.     differs.doc, "SZADB Primer", the source
  460.  
  461. BUGS
  462.  
  463. Despite of a support for displays of different sizes a program input
  464. buffer is fixed and will accept upto 78 characters from a keyboard.
  465. This can be construed as a feature.
  466.  
  467. WHERE TO GET SOZOBON C
  468.  
  469. Sozobon C is freely distributed through many bulletin boards and computer
  470. networks worldwide.  If you cannot find it anywhere locally, you can
  471. always order the newest release from us directly.  Send $10 US to cover
  472. shipping, handling and floppies (add a couple $ for European orders) to
  473.  
  474.         Tony Andrews
  475.         5902E Gunbarrel Ave.
  476.         Boulder, Colorado USA  80301
  477.  
  478. After March 30, 1990 this will change to
  479.  
  480.         Tony Andrews
  481.         4704 Berkshire Court
  482.         Boulder, Colorado USA  80301
  483.  
  484. Make checks payable to Tony Andrews.  Specify single or double sided
  485. floppies (you will get double sided if you don't say anything).
  486.  
  487. If you don't need the release, but you want to encourage further product
  488. development from Sozobon Ltd, we will gladly accept money, ST software
  489. such as games you don't play anymore, freeware or shareware you have
  490. written with Sozobon and/or simple words of encouragement.
  491.  
  492.  
  493. LEGALESE
  494.  
  495. /* Copyright (c) 1990 by Sozobon, Limited.  Authors: Johann Ruegg, Don Dugger
  496.  * Modifications for version 1.2(mj+ach): Anthony Howe, Michal Jaegermann
  497.  * Version 1.4 with support for Moniterm and TT screens - Michal Jaegermann
  498.  *
  499.  * Permission is granted to anyone to use this software for any purpose
  500.  * on any computer system, and to redistribute it freely, with the
  501.  * following restrictions:
  502.  * 1) No charge may be made other than reasonable charges for reproduction.
  503.  * 2) Modified versions must be clearly marked as such.
  504.  * 3) The authors are not responsible for any harmful consequences
  505.  *    of using this software, even if they result from defects in it.
  506.  */
  507.  
  508. UNIX is a trademark of AT&T (it used to be a trademark of Bell Labs)
  509. Mark Williams C is a trademark of Mark Williams Company
  510.  
  511. AUTHORS
  512.  
  513.     original:
  514.     Johann Ruegg      uunet!dunike!onecom!wldrdg!hans
  515.     Don Dugger      uunet!dunike!onecom!wldrdg!n0ano
  516.     modifications for version 1.2:
  517.     Anthony Howe      ant@mks.com
  518.     Michal Jaegermann ntomczak@ualtavm.bitnet
  519.     updates for versions 1.3, 1.4
  520.     Michal Jaegermann ntomczak@vm.ucs.ualberta.ca
  521.